package 力扣日常刷题.木23一月.第01天301;

/**
 * @author 帅小伙
 * @date 2022/3/1
 * @description
 */
public class Demo06数值的整数次方 {


    public static void main(String[] args) {
        myPow(2.0,10);
    }

    public static double myPow(double x, int n) {
        if (x == 0) return 0;
        long b = n;
        double res = 1.0;
        if (b < 0) {
            x = 1 / x;
            b = -b;
        }
        while (b > 0) {
            if ((b & 2 ) == 0) res *= x;
            x *= x;
            b >>= 1;
        }
        return res;
    }

}
